package com.zs.demo.common.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/* @Desc: 请求响应结果集
 * @author:zhengs  
 * @Time: 2018/11/20 10:00
 * @Copyright: © zhengs 版权所有  
 * @Warning: 本内容仅限于本公司内部传阅,禁止外泄或用于其它商业目的
 */
@Data
@ApiModel(value = "响应结果集")
public class ResponseData<T> implements Serializable {
    @ApiModelProperty(value = "响应状态码")
    private Integer status;

    @ApiModelProperty(value = "响应数据")
    private T data;

    @ApiModelProperty(value = "响应消息")
    private String msg;

    public ResponseData(IResponseStatus status) {
        initConstructor(status.getStatus(),status.getMsg());
    }

    public ResponseData(T data, IResponseStatus status) {
        this.data = data;
        initConstructor(status.getStatus(),status.getMsg());
    }

    public ResponseData(Integer code,String msg) {
        initConstructor(code,msg);
    }

    private void initConstructor(Integer code,String msg){
        this.status = code;
        this.msg = msg;
    }
}
